package cn.csust.net2.manager.server.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.csust.net2.manager.server.dao.BaseDAO;
import cn.csust.net2.manager.server.remote.BeanUtils;
import cn.csust.net2.manager.shared.exception.BeyondAuthorityException;
import cn.csust.net2.manager.shared.po.Banji;
import cn.csust.net2.manager.shared.po.PO;
import cn.csust.net2.manager.shared.service.NoticeService;
import cn.csust.net2.manager.shared.util.ServiceConstant;

import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.PagingLoadConfig;

@Service(value = ServiceConstant.SERVICE_NAME_NOTICE)
public class NoticeServiceImpl  extends BaseServiceImpl  implements  NoticeService{
	/**
	 * 条件加载
	 */
	@Transactional
	@Override
	public <T extends PO>  BasePagingLoadResult<T> findAll(String cla,PagingLoadConfig config)throws BeyondAuthorityException {
		Banji banji = config.get("banji");
		BaseDAO<T> dao = BeanUtils.getBean(cla);
		if(banji!=null){
			String  hql = "from Notice c where c.banji.banjiID = " + banji.getBanjiID();
			return dao.findAllByPaging(config, hql);
		}
		else
			return dao.findAllByPaging(config);
	}
}
